<template>
	<view style="width: 90%; margin: 0 auto;padding-top: 25px;">
		<text style="font-size: 30rpx;">您的昵称：</text>
		<view> <input type="text" value="" v-model="c" class="pe" /></view>
		<text style="font-size: 30rpx; ">登录密码：</text>
		<view> <input type="text" value="" v-model="ccc" class="pe" /></view>
		<!-- 插件 -->
		<uni-combox label="城市名称:" :candidates="candidates" placeholder="请选择所在城市" v-model="city"></uni-combox>
		<uni-combox label="省份名称:" :candidates="provincesss" placeholder="请选择所在省份" v-model="province"></uni-combox>
		<!-- #ifdef MP-WEIXIN -->
		<button type="primary" @click="weixingxcx">保存</button>
		<!-- #endif -->
		
	</view>
</template>

<script>
	import uniCombox from "../../components/uni-combox/uni-combox.vue"
	export default {
		data() {
			return {
				c: '',
				cc: '',
				ccc: '',
				// 插件
				candidates: [
					'茂名',
					'广州',
					'深圳',
					'东莞'
				], 
				city: '广州',
				provincesss: ["广东省", "广西省"],
				province: '广东省'
			}
		},
		methods: {
			// 抽离方法（没整合）
			weixingxcx()
			{
				var token = uni.getStorageSync('user_token');
				if (this.cc != this.ccc) {
					uni.showToast({
						title: "两次密码不一样哦",
						icon: 'none',
						duration: 2000
					});
					this.ccc = this.cc = ""
				} else if (this.cc == '') {
					uni.showToast({
						title: "密码不能为空",
						icon: 'none',
						duration: 2000
					});
				} else {
					console.log("success", token, this.c, this.cc, this.ccc)
					// 发送
					uni.request({
						url: "http://106.13.76.186/api/user/resetpwd",
						method: "POST",
						header: {
				
							'token': token, //自定义请求头信息
				
						},
						data: {
							"newpassword": this.ccc,
							"type": "pwd1",
							"oldpassword": this.c
						},
						success: e => {
				
							console.log(e)
							uni.showToast({
								title: e.data.msg,
								icon: 'none',
								duration: 2000
							});
						}
					})
				}
			},
			onNavigationBarButtonTap(e) {
				this.weixingxcx()
			},
		},
		components: {
			uniCombox
		}
	}
</script>

<style lang="less" scoped>
	.pe {
		width: 100%;
		height: 30px;
		border-bottom: 1px solid #4CD964;
	}
</style>
